package com.alibaba.citrus.cr.mn.order.center.facade.adapter.convert;

import com.alibaba.citrus.cr.mn.order.center.facade.adapter.dataobject.response.CustomerSaleScopeDTO;
import com.alibaba.citrus.cr.mn.order.center.facade.function.convert.BeanConverter;
import com.alibaba.lattice2.epoch.sdk.model.Result;
import com.epoch.app.crplatformenhance.domain.customersalescope.model.CustomerSaleScope;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author zhangxiaorui
 * @ClassName CustomerSaleScopeAdapterConvertor
 * @description: TODO
 * @date 2023/05/08 17:13
 * @version: 1.0
 */
public class CustomerSaleScopeAdapterConvertor {

    public static List<CustomerSaleScopeDTO> convert(Result<List<CustomerSaleScope>> listResult) {

        if (Objects.isNull(listResult) || CollectionUtils.isEmpty(listResult.getResult())) {
            return Lists.newArrayList();
        }

        return listResult.getResult().stream().map(tmp -> {
            // TODO 此处可以考虑字段瘦身
            return BeanConverter.convert(tmp, new CustomerSaleScopeDTO());
        }).collect(Collectors.toList());
    }
}
